//package com.link.base.user.controller;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import OnlineUser;
//import OnlineRedisUserService;
//import OnlineUserService;
//import com.link.base.user.service.OnlineUserTaskServiceImpl;
//import com.link.core.basic.controller.BasicController;
//import com.link.core.basic.query.QueryParams;
//import com.link.core.basic.service.BasicService;
//
//
//@Controller
//@RequestMapping("/link/online")
//public class PortalOnlineUserController extends BasicController<OnlineUser>{
//    private static final Logger logger = LogManager.getLogger(PortalOnlineUserController.class);
//    @Resource
//    private OnlineUserService onlineUserService;
//
//    @Resource
//    private OnlineUserTaskServiceImpl onlineUserTaskService;
//
//    @Resource
//    private OnlineRedisUserService onlineRedisUserService;
//
//    @Override
//    public BasicService<OnlineUser>  getBasicService() throws Exception{
//        return onlineUserService;
//    }
//
//    /**
//     * 一)功能：修复数据。
//     * 二)原因：由于服务器非正常方式关闭会导致在线用户表不能及时删除数据，导致数据冗余。
//     * 三)实现原理：通过遍历匹配服务器上的sessionId和在线用户表的sessionId字段，找出在线用户表的冗余记录，并且删除
//     */
//    @RequestMapping(value = "/dataRecovery")
//    @ResponseBody
//    public Map<String, Object> dataRecovery(HttpSession session, HttpServletRequest request, HttpServletResponse response) {
//        return onlineUserTaskService.dataRecovery();
//    }
//
//    /**
//     * @author huanglongjian
//     */
//    @RequestMapping(value = "/shotOff" , method= { RequestMethod.GET, RequestMethod.POST} )
//    @ResponseBody
//    public Map<String, Object> shotOffUser(OnlineUser onlineUser,
//                HttpSession session, HttpServletRequest request, HttpServletResponse response) {
//            Map<String, Object> result = new HashMap<String, Object>();
//            try {
//                if("WEB".equals(onlineUser.getLoginType())) {
//                    onlineRedisUserService.deleteCRMSessionById(onlineUser.getSessionId());
//                }else if("APP".equals(onlineUser.getLoginType())){
//                    onlineRedisUserService.deleteAPPSessionById(onlineUser.getSessionId());
//                }
//                result.put("success", true);
//                result.put("result","");
//            }catch(Exception e) {
//                result.put("success", false);
//                result.put("result", e.getMessage());
//            }
//            return result;
//    }
//
//    @Override
//    @RequestMapping(value = "/queryByExamplePage")
//    @ResponseBody
//    public Map<String, Object> queryByExamplePage(QueryParams qps, OnlineUser entity, HttpSession session,
//            HttpServletRequest request, HttpServletResponse response) {
//        Map<String, Object> result = new HashMap<String, Object>();
//        try{
//            List<OnlineUser> list = onlineRedisUserService.queryOnline();
//            result.put("success", true);
//            result.put("rows", list);
//            //this.pushCurrentDataCache(list, session.getId(), "base", false);
//            //result.put("total", getCount((BasicModel)t, list.size()));
//        }catch(Exception e){
//            result.put("success", false);
//            result.put("rows", new ArrayList<OnlineUser>());
//            result.put("result", e.getMessage());
//        }
//        return result;
//    }
//
//
//}
